package org.jackysoft.interceptor;

import java.lang.reflect.Method;

import org.apache.commons.beanutils.PropertyUtils;

import com.opensymphony.xwork2.ActionInvocation;

public class GetsInterceptor extends
		AbstractInterceptor {

	/**
	 * 
	 */
	private static final long serialVersionUID = 8149029777540594927L;

	@Override
	public String intercept(ActionInvocation ai) throws Exception {
		super.intercept(ai);
		Object action = ai.getAction();
	
		Method service_m_gets = service.getClass().getMethod(SERVICE_GETS_BEAN_);
		// 从数据库查询得到的对象
		Object targetBeans = service_m_gets.invoke(service);		
				
		PropertyUtils.setProperty(action, "beans", targetBeans);
		return ai.invoke();
	}
}
